# Makefile for dviljk -- kb@mail.tug.org.  Public domain.
version = 2.6

.NOTPARALLEL:

kpse_include ../make/paths.mk
kpse_include ../make/common.mk
kpse_include ../make/programs.mk

prog_cflags = -DKPATHSEA

common_objects = tfm.o

program = dvilj
objects = dvilj.o $(common_objects)
objects2p = dvilj2p.o $(common_objects)
program2p = dvilj2p
objects4 = dvilj4.o $(common_objects)
program4 = dvilj4
objects4l = dvilj4l.o $(common_objects)
program4l = dvilj4l
program6 = dvilj6

programs = $(program) $(program2p) $(program4) $(program4l)

default: $(program4)
all: $(programs)

$(program): $(objects) $(kpathsea)
	$(kpathsea_link) $(objects) $(LOADLIBES)
$(program2p): $(objects2p) $(kpathsea)
	$(kpathsea_link) $(objects2p) $(LOADLIBES)
$(program4): $(objects4) $(kpathsea)
	$(kpathsea_link) $(objects4) $(LOADLIBES)
$(program4l): $(objects4l) $(kpathsea)
	$(kpathsea_link) $(objects4l) $(LOADLIBES)

dvilj.o:
	$(compile) -c -DLJ $(srcdir)/dvi2xx.c -o $@
dvilj2p.o:
	$(compile) -c -DLJ2P $(srcdir)/dvi2xx.c -o $@
dvilj4.o:
	$(compile) -c -DLJ4 $(srcdir)/dvi2xx.c -o $@
dvilj4l.o:
	$(compile) -c -DLJ4 -DLJ4L $(srcdir)/dvi2xx.c -o $@

dvilj.o dvilj2p.o dvilj4.o dvilj4l.o: dvi2xx.c

kpse_include ../make/tkpathsea.mk

install: install-exec install-data
uninstall: uninstall-exec uninstall-data

install-exec:
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(bindir)
	test ! -f $(program) \
	  || $(INSTALL_LIBTOOL_PROG) $(program) $(bindir)
	test ! -f $(program2p) \
	  || $(INSTALL_LIBTOOL_PROG) $(program2p) $(bindir)
	test ! -f $(program4) \
	  || $(INSTALL_LIBTOOL_PROG) $(program4) $(bindir)
	test ! -f $(program4l) \
	  || $(INSTALL_LIBTOOL_PROG) $(program4l) $(bindir)
	$(INSTALL_SCRIPT) $(srcdir)/dvihp $(scriptdir)/dvihp
	cd $(bindir) && (rm -f $(program6); $(LN) $(program4) $(program6))
uninstall-exec:
	cd $(bindir); rm -f $(programs)

install-data:
	$(SHELL) $(top_srcdir)/../mkinstalldirs $(man1dir)
	$(INSTALL_DATA) $(srcdir)/dvilj.man $(man1dir)/dvilj.$(manext)
	for p in dvilj2p dvilj4 dvilj4l dvilj6; do \
	  rm -f $(man1dir)/$$p.$(manext); \
	  ln -s dvilj.$(manext) $(man1dir)/$$p.$(manext); \
	done
	$(INSTALL_DATA) $(srcdir)/dvihp.man $(man1dir)/dvihp.$(manext)

# It seems simplest to keep this separate. Use find and cpio instead of
# just cp -r in case the source hierarchy is cvs- or rcs-ified.
# Use "" to quote wildcards because backslash is a directory separator
# on MS-DOS and MS-Windows.
install-fonts:
	find fonts -name \( "*.tfm" -o -name "*.vf" \) -print | cpio -pld $(texmf)

uninstall-data:
	rm -f $(man1dir)/dvilj.$(manext)


distname = dviljk
program_files = dvihp dvilj.man README.fonts
version_files = dvi2xx.c dvihp

pre-dist-$(distname):
post-dist-$(distname):
	ln -s `pwd`/fonts `pwd`/tex `pwd`/src.fonts $(distdir)

kpse_include ../make/dist.mk
kpse_include ../make/config.mk

info dvi check:

kpse_include ../make/clean.mk

kpse_include ../make/rdepend.mk
kpse_include depend.mk
